package com.cv.framework.web.core.filter;

import cn.hutool.core.util.StrUtil;
import com.cv.framework.web.config.WebProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.http.HttpServletRequest;

/**
 * API 请求过滤器
 *
 * @author Charles_XDXD
 */
@RequiredArgsConstructor
public abstract class ApiRequestFilter extends OncePerRequestFilter {

    protected final WebProperties webProperties;

    @Override
    protected boolean shouldNotFilter(HttpServletRequest request) {
        // 只过滤 API 请求的地址
        return !StrUtil.startWithAny(
                request.getRequestURI(),
                webProperties.getPlatformApi().getPrefix(),
                webProperties.getSystemApi().getPrefix(),
                webProperties.getAuditApi().getPrefix(),
                webProperties.getTusApi().getPrefix()
        );
    }

}
